package com.dingding.order.core.confirm.dao.impl;

import java.math.BigDecimal;

import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.dingding.common.core.base.dao.impl.BaseDaoImpl;
import com.dingding.common.core.beans.Userorder;
import com.dingding.order.core.confirm.dao.IUserOrderDao;
import com.dingding.order.core.confirm.sql.ConfirmSQL;

@Component("userOrderDao")
public class UserOrderDaoImpl extends BaseDaoImpl<Userorder> implements IUserOrderDao{

	/**
	 * 
	 * 订单完成后，如果用户参加活动有可能赠送积分。
	 * 如果赠送积分需要将获赠积分数更新到订单表中，当前接口由此产生
	 * 
	 * @Title: updateCurrentOrderReceiveIntegral 
	 * @param: receiveIntegral 赠送积分
	 * @para: orderId 订单ID
	 * @return    设定文件 
	 * @author CHEHAUNBO
	 * 
	 */
	@Override
	@Transactional(propagation=Propagation.REQUIRED)
	public boolean updateCurrentOrderReceiveIntegral(BigDecimal receiveIntegral, String orderId) {

		try {

			int row = super.updateSqlRow(ConfirmSQL.UPDATE_CURRENTORDER_RECEIVE_INTEGRAL, receiveIntegral,
					orderId);
			if (row > 0) {
				return true;
			}
		} catch (Exception e) {
			log.error("设置订单为已评价出现异常！订单ID为：" + orderId);
		}
		return false;

	}
	
}
